package leetcode.leetcode100;

public class maxArea {
    public static void main(String[] args) {
        int[] arr = {1,8,6,2,5,4,8,3,7};
        System.out.println(process(arr));
    }
    public static long process(int[] height){
        int p1 = 0;
        int p2 = height.length-1;
        int length = height.length -1;
        long max = Math.min(height[p1],height[p2])*length;
        while (p1!=p2 && length>0){
            if (height[p1] > height[p2]){
                p2--;
                length--;
            }else {
                p1++;
                length--;
            }
            long cur = Math.min(height[p1],height[p2])*length;
            max = Math.max(max,cur);
        }
        return max;
    }
}
